<?php

class StudyManager {

    function StudyManager() {
    }
    
    public function execute() {
    }
    
    public function getBlacklist() {
    	global $page;
    	$where = "";
    	if($_POST[qq]&&$_POST[qq]!="") {
    		$where = $where." AND a.qq like '{$_POST[qq]}%'";
    	}
    	$start_time = date("YmdHis", (time() + 8 * 3600));
    	$sql = "select a.*,b.update_time,b.nick from td_blacklist a ".
    		   "LEFT JOIN td_normal_user_info b on a.qq = b.qq where 1=1 and a.flag=1 and end_time > '{$start_time}' {$where} order by a.day desc limit {$_REQUEST[start]},{$_REQUEST[limit]}" ;
    	$sqlC =  "SELECT count(DISTINCT a.qq) cou from td_blacklist a ".
    		   "LEFT JOIN td_normal_user_info b on a.qq = b.qq where 1=1 and a.flag=1 and end_time > '{$start_time}' {$where}" ;
    
    	$rs = DB::GetQueryResult($sql,false,0);
    	$cou = DB::GetQueryResult($sqlC,true,0);
    	$page->totalProperty = $cou[cou];
    	$arr = array();
    	$i=0;
    	foreach($rs as $x) {
    		if($x[update_time] && $x[update_time]!="") { 
    			$upt = substr($x[update_time],5);
    		} else {
    			$upt = "--";
    		}
    		if($x[keword] && trim($x[keword])!="") {
    			$k = $x[keword];
    		} else {
    			$k = "--";
    		}
    		$endTime = substr($x[end_time],0,4).'-'.substr($x[end_time],4,2).'-'.substr($x[end_time],6,2).' '.substr($x[end_time],8,2).':'.substr($x[end_time],10,2).':'.substr($x[end_time],12,2);
    		$tem = array(
    			'id'=>$x[id],
    			'qq'=>$x[qq],
    			'nick'=>$x[nick],
    			'updateTime'=>$upt,
    			'day'=>$x[day],
    			'keword'=>$k,
    			'cluster'=>$x[clusternum],
    			'endTime'=>$endTime
    		);
    		$arr[$i++] = $tem;
    	}
    	$page->root = $arr;
    }
}
?>